package Exercises;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpDictSever extends UdpEchoServer{
    private Map<String,String> dict = new HashMap<>();
    public UdpDictSever(int port)throws SocketException {
        super(port);
        dict.put("cat","小猫");
        dict.put("dog","小狗");
        dict.put("pig","小猪");
        dict.put("sheep","小羊");
    }
    @Override
    public String process(String request){
        return dict.getOrDefault(request,"未查到");
    }

    public static void main(String[] args) throws IOException {
        UdpDictSever sever = new UdpDictSever(9090);
        sever.start();
    }
}
